package com.dyypdadmin.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dyypdadmin.pojo.ServiceDetails;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ServiceDetailsDao extends BaseMapper<ServiceDetails> {

    @Insert("INSERT INTO servicedetails (service_type_id, service_name, service_price, service_description) VALUES (#{service_type_id}, #{service_name}, #{service_price}, #{service_description})")
    int addServiceDetails(@Param("service_type_id") int service_type_id,
                          @Param("service_name") String service_name,
                          @Param("service_price") String service_price,
                          @Param("service_description") String service_description);

    @Update("UPDATE servicedetails SET is_del = 0 WHERE service_detail_id = #{service_detail_id}")
    int deleteServiceDetailsById(@Param("service_detail_id") int service_detail_id);

    @Update("UPDATE servicedetails SET service_name = #{service_name},service_price = #{service_price}, service_description = #{service_description},is_appointment_available = #{is_appointment_available} WHERE service_detail_id = #{service_detail_id}")
    int updateServiceDetails(ServiceDetails serviceDetails);

    @Select("SELECT * FROM servicedetails WHERE service_detail_id = #{service_detail_id}")
    ServiceDetails getServiceDetailsById(@Param("service_detail_id") int service_detail_id);

    @Select("select * from servicedetails where service_type_id =#{service_type_id}")
    List<ServiceDetails> getListByType(@Param("service_type_id") int service_type_id);

    @Select("select * from servicedetails")
    List<ServiceDetails> getAll();

    //修改服务可使用状态
    @Update("update servicedetails set is_appointment_available=#{is_appointment_available},is_del=#{is_del} where service_detail_id=#{service_detail_id}")
    int changeStatus(@Param("service_detail_id")Integer service_detail_id,@Param("is_appointment_available")Integer is_appointment_available,@Param("is_del")Integer is_del);

    //根据服务名称获取数据
    @Select("select * from servicedetails where service_name=#{service_name}")
    List<ServiceDetails> getDetailByName(@Param("service_name")String service_name);

    //添加新的服务
    @Insert("insert into servicedetails(service_type_id, service_name, service_price, service_description) VALUES (#{service_type_id},#{service_name},#{service_price},#{service_description})")
    int insertServiceDetail(ServiceDetails serviceDetails);
}